//  MineAccountTBV.m
//  XJMTechnician
//  Created by Mr.hu on 2017/10/17.
//  Copyright © 2017年 Mr.hu. All rights reserved.

#import "MineAccountTBV.h"
#import "DetailIncomeTBV.h"
#import "CashHandFirstTBV.h"
#import "PaySecretFirst.h"

@interface MineAccountTBV ()
@property (weak, nonatomic) IBOutlet UIButton *backProViewBtn;
@property (weak, nonatomic) IBOutlet UIButton *DetailncomeBtn;
@property (weak, nonatomic) IBOutlet UILabel *IncomeMoneyLab;
@property (weak, nonatomic) IBOutlet UIButton *ComminteIncome;

@property (weak, nonatomic) IBOutlet UIButton *FirstCircleBtn;
@property (weak, nonatomic) IBOutlet UIButton *SecondCircleBtn;
@property (weak, nonatomic) IBOutlet UIButton *ThreeCircleBtn;
@property (weak, nonatomic) IBOutlet UIButton *FourCircleBtn;
@property (weak, nonatomic) IBOutlet UIButton *FiveCircleBtn;

@end

@implementation MineAccountTBV

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addLeftBtn:[UIImage imageNamed:@"fanhui"] Action:@selector(backToPrevious)];
    self.title = @"我的账户";
  
    CGRect labelSize = [@"账户明细" boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, 30) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 0, labelSize.size.width+10, 30);
    btn.titleLabel.font = [UIFont systemFontOfSize:16];
    [btn setTitleColor:RGBA(234, 0, 0, 1) forState:UIControlStateNormal];
    [btn setTitle:@"账户明细" forState:UIControlStateNormal];
    [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    [btn addTarget:self action:@selector(AccountDetailMeth) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
    
    if (self.Input_price == nil || self.Input_price == NULL || [self.Input_price isEqualToString:@"null"]) {
        self.IncomeMoneyLab.text = [NSString stringWithFormat:@"¥0"];
    }else{
        self.IncomeMoneyLab.text = [NSString stringWithFormat:@"¥%@",self.Input_price];
    }
    
    [self CircleMaskBottom]; //提现规则
}

- (void)CircleMaskBottom{
    
    [XJHttpClass myAccountRuleToken:[XJToolClass getToken] andFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
            [XJToolClass tipAnimationWith:errStr];
        }else{
            
        }
    }];
    
}


- (void)AccountDetailMeth{
    
    DetailIncomeTBV * detailincome = [[DetailIncomeTBV alloc]init];
    detailincome.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:detailincome animated:YES];
    
}

- (IBAction)IncomeComminteMeth:(id)sender {
    
    if (self.Input_price.integerValue >= 50) {
    
    //如果未设置支付密码
    [XJHttpClass checkPaySecrettoken:[XJToolClass getToken] andFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
            [XJToolClass tipAnimationWith:errStr];
            if ([errStr isEqualToString:@"未设置支付密码"]) {
                PaySecretFirst * cashhand = [[PaySecretFirst alloc]init];
                [self.navigationController pushViewController:cashhand animated:YES];
            }
        }else{
                CashHandFirstTBV * cashhand = [[CashHandFirstTBV alloc]init];
                cashhand.CashHand_price = self.IncomeMoneyLab.text;
                cashhand.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:cashhand animated:YES];
        }
    }];
         
     }else{
         [XJToolClass tipAnimationWith:@"余额不足,无法提现!"];
     }
}

@end
